uniDecode
Type
function
Summary
Converts a string from Unicode to single-byte text.
Syntax
the uniDecode of <stringToDecode>
uniDecode(<stringToDecode> [, <language>])
Description
Use the uniDecode function to convert double-byte characters to single-byte characters.
As of LiveCode 7.0 the uniDecode function has been deprecated. It will continue to work as in previous versions but should not be used in newcode as the existing behaviour is incompatible with the new, transparent Unicode handling (the resulting value will be treated as binary data rather than text). This function is only useful in combination with the also-deprecated uniEncode function and unicodeText field property. Instead, for converting text between encodings, use the textEncode and textDecode functions.
The uniDecode function is the inverse of the uniEncode function and removes the null bytes inserted for Unicode compatibility. In other words, it turns double-byte characters into their closest single-byte equivalent.
If the stringToDecode contains an odd number of bytes, the last byte is ignored.
You can use the UTF8 encoding only with the uniDecode and uniEncode functions. You cannot set an object's textFont property to use UTF-8. To display Unicode text in an object, use either "Unicode" or a language name as the second item of the object's textFont.
The format expected by the uniDecode function is processor-dependent. On "little-endian" processors, where the first byte is least significant (such as Intel and Alpha processors), the uniDecode function removes the second byte of each character. On "big-endian" processors, where the last byte is least significant (such as PowerPC processors), the uniDecode function removes the first byte of each character.
The ability to handle double-byte characters on "little-endian" processors was added in LiveCode 2.0. In previous versions, the uniDecode function always removed the second byte of each pair of bytes, regardless of platform.
The ability to convert Unicode text into language-specific encodings was added in LiveCode 2.0. In previous versions, the uniDecode function simply removed every other byte.
Parameters
Name | Type | Description |
---|---|---|
stringToDecode | string | any string, or expression that evaluates to a string. |
language | enum |
Examples
uniDecode("A" & numToChar(zero)) -- returns "A" (on PPC)
uniDecode("ABCDE") -- returns "BD" (on Intel)
uniDecode(field "JIS Input","Japanese") -- converts to JIS
Related
function: format, platform, textDecode, textEncode, uniEncode
glossary: byte, function, object, property, return, Unicode
keyword: character, characters, inverse
property: textFont, unicodeText
constant: null
control structure: function
Compatibility and Support
Introduced
LiveCode 1.0
OS
mac
windows
linux
ios
android
Platforms
desktop
server
mobile